package com.jinmdz.fmis.mapper.mapper;

import com.jinmdz.fmis.mapper.entity.FamilyAgentEntity;
import com.jinmdz.fmis.mapper.mapper.provider.FamilyAgentProvider;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

/**
 * 承办人表Mapper
 *
 * @author generator
 * @date 2020-03-12 17:08
 */
public interface FamilyAgentMapper {

    /**
     * 增加FamilyAgent
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @InsertProvider(type = FamilyAgentProvider.class, method = "insertFamilyAgent")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertFamilyAgent(@Param("entity") FamilyAgentEntity entity);

    /**
     * 删除FamilyAgent
     *
     * @param id             主键
     * @param modifiedUserId 修改用户外键
     * @param version        版本号
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @Update(" update family_agent set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForFamilyAgent(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改FamilyAgent
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @UpdateProvider(type = FamilyAgentProvider.class, method = "updateFamilyAgent")
    void updateFamilyAgent(@Param("entity") FamilyAgentEntity entity);

    /**
     * 查询FamilyAgent实体
     *
     * @param id 主键
     * @return FamilyAgentEntity
     * @author generator
     * @date 2020-03-12 17:08
     */
    @Select(" select id,deleted,business_code,agent_type,agent_unit_name,agent_name,agent_gender_code,certificate_type_code,certificate_no,agent_relation,mobile_phone,other_phone,address,remark,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from family_agent where id = #{id} and deleted = 0 limit 1 ")
    FamilyAgentEntity getFamilyAgentById(@Param("id") Integer id);

    /**
     * 查询FamilyAgent列表
     *
     * @param entity 数据实体
     * @return FamilyAgentEntity
     * @author generator
     * @date 2020-03-12 17:08
     */
    @SelectProvider(type = FamilyAgentProvider.class, method = "listFamilyAgent")
    ArrayList<FamilyAgentEntity> listFamilyAgent(@Param("entity") FamilyAgentEntity entity);
}